package com.rdc.dictionary.daily;

import android.annotation.SuppressLint;
import android.os.Handler;

import android.os.Message;
import android.widget.Toast;

import com.rdc.dictionary.application.App;
import com.rdc.dictionary.bean.DailySentence;
import com.rdc.dictionary.mvpPresenters.BasePresenter;



/**
 * @author Soul Mate
 * @file 文件名
 * @brief 每日一句活动中的presenter
 */

public class DailyPresenter extends BasePresenter<DailyActivityContract.IMainView>
		implements DailyActivityContract.IMainPresenter , DailyActivityContract.onGetData
{

	private DailyActivityContract.IMainView mView ;

	private DailyModel mModel =new DailyModel();

	//创建view时去activity执行获取view
	//坑死
	@Override
	public void init()
	{
		mView = getMvpView();

		//设置数据获取的监听
		mModel.setListener(this);
	}


	/**
	*发起请求数据
	*/
	@Override public void send()
	{
		mModel.sendRequestWithOkHttp();

	}

	@Override
	public void onSuccess(DailySentence data)
		{
			//显示信息
			mView.get(mModel.getDaily());
			mView.showData(mModel.getDaily());


		}

	@Override
	public void onFail()
	{
		Toast.makeText(App.sContext , "获取失败，请检查网络", Toast.LENGTH_SHORT).show();

	}

}